//引入二次封装的网络请求
import service from '../utils/request';

//获取分类
export const reqCategory = () => service({
  url: '/mall-api/index/findCategoryTree'
});
//获取用户身份标识token
export const reqLogin = (code) => service({
  url: `/mall-api/weixin/wxLogin/${code}`
});
//获取用户信息
export const reqUserInfo = () => service({
  url: '/mall-api/weixin/getuserInfo'
});
//更新用户信息
export const reqUpdateUser = (data) => service({
  url: '/mall-api/weixin/updateUser',
  method: 'post',
  data
});
//获取商品列表的接口
export const reqGoodsList = (page, limit, category2Id) => service({
  url: `/mall-api/goods/list/${page}/${limit}?category2Id=${category2Id}`
});
//获取用户购物车
export const reqCartList = () => service({
  url: `/mall-api/cart/getCartList`
});
//更新某一个商品的勾选的状态
export const reqUpdateChecked = (goodsId, isChecked) => service({
  url: `/mall-api/cart/checkCart/${goodsId}/${isChecked}`
});
//更新全部的勾选的状态
export const reqUpdateAllChecked = (isChecked) => service({
  url: `/mall-api/cart/checkAllCart/${isChecked}`
});

//更新商品的数量|将商品加入购物车
export const reqAddOrUpdateCart = (goodsId, count, blessing) => service({
  url: `/mall-api/cart/addToCart/${goodsId}/${count}?blessing=${blessing}`
});
//删除某一个商品
export const reqDeleteGoods = (goodsId) => service({
  url: `/mall-api/cart/delete/${goodsId}`
});

//获取某一个商品的详情信息
export const reqGoodsInfo = (goodsId) => service({
  url: `/mall-api/goods/${goodsId}`
})


//获取订单详情页购物车的
export const reqOrderGoodsList = () => service({
  url: '/mall-api/order/trade'
});
//获取某一个商品的接口
export const reqOrderBuyGoods = (goodsId, blessing) => service({
  url: `/mall-api/order/buy/${goodsId}?blessing=${blessing}`
});


//订单详情页默认收货人信息
export const reqOrderUserInfo = () => service({
  url: '/mall-api/userAddress/getOrderAddress'
});

//微信小程序提交订单接口
export const reqSubmitOrder = (data) => service({
  url: '/mall-api/order/submitOrder',
  method: 'post',
  data
})
//2:获取支付的信息
export const reqGetPayInfo = (orderNo) => service({
  url: `/mall-api/webChat/createJsapi/${orderNo}`
})

//查询支付的结果
export const reqPayResult = (orderNo) => service({
  url: `/mall-api/webChat/queryPayStatus/${orderNo}`
})

// 新增收货人地址
export const reqAddUserAddress = (data) => service({url:'/mall-api/userAddress/save',method:'POST',data});
// 获取当前所有地址
export const reqAllUser = () =>service({url:'/mall-api/userAddress/findUserAddress'})